package com.example.wechat_b.utils;

import android.graphics.Rect;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

/**
 * @author liaoqg
 * @brief description
 * @date 2021-11-05
 */
public class SpaceItemDecoration extends RecyclerView.ItemDecoration {

    private int space;
    private final int type;
    public static int FIND_RECYCLE_DECORATION = 1;
    public static int MINE_RECYCLE_DECORATION = 2;

    public SpaceItemDecoration(int type,int space){
        this.space = space;
        this.type = type;
    }

    @Override
    public void getItemOffsets(Rect outRect,View view,RecyclerView parent,RecyclerView.State state) {
        switch (type){
            case 1:
                if (parent.getChildAdapterPosition(view)==0){
                    outRect.bottom = space;
                }
                if (parent.getChildAdapterPosition(view)==1){
                    outRect.bottom = space;
                }
                if (parent.getChildAdapterPosition(view)==3){
                    outRect.bottom = space;
                }
                if (parent.getChildAdapterPosition(view)==5){
                    outRect.bottom = space;
                }
                if (parent.getChildAdapterPosition(view)==6){
                    outRect.bottom = space;
                }
                if (parent.getChildAdapterPosition(view)==8){
                    outRect.bottom = space;
                }
                if (parent.getChildAdapterPosition(view)==9){
                    outRect.bottom = space;
                }
                break;
            case 2:
                if (parent.getChildAdapterPosition(view)==0){
                    outRect.bottom = space;
                }
                if (parent.getChildAdapterPosition(view)==4){
                    outRect.bottom = space;
                }
                break;
        }
    }
}
